const xml2js = require('xml2js');
const fs = require('fs');

const xmlParser = new xml2js.Parser();

var xmlData = fs.createReadStream('city.xml');

var data = '';

xmlData.on('data', rs=>{
    data += rs;

    xmlParser.parseString(data, (err, res)=>{
        if (err) throw err;
        var strJson =  JSON.stringify(res);
        var writeStream = fs.createWriteStream('city.json');
        writeStream.write(strJson);
        writeStream.end();
    })
})